package com.abdd.hbxs_api.mapper;

import com.abdd.hbxs_api.pojo.Userinfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserinfoMapper {

    @Select("select * from v_userinfo")
    List<Userinfo>findAll();

    @Select("select * from v_userinfo where user_id=#{id}")
    Userinfo findById(int id);

    @Select("select * from v_userinfo where user_name=#{name}")
    Userinfo findByName(String name);

//    @Insert("insert into v_userinfo(user_id, user_name, user_password) values (#{id}, #{name}, #{password})")
//    void insert(@Param("id") int id, @Param("name") String name, @Param("password") String password);
    @Insert("insert into v_userinfo(user_id, user_name, user_password, user_sex, user_age, user_phone, user_account, user_address) " +
            "values (#{userId}, #{userName}, #{userPassword}, #{userSex}, #{userAge}, #{userPhone}, #{userAccount}, #{userAddress})")
    void insert(Userinfo userinfo);

    @Update("update v_userinfo set  " +
            "user_name = #{userName}, user_password = #{userPassword}, user_sex = #{userSex}, user_age = #{userAge}, user_phone = #{userPhone}, user_account = #{userAccount}, user_address = #{userAddress}" +
            "where user_id = #{userId}")
    void update(Userinfo userinfo);

    @Delete("delete from v_userinfo where user_id=#{userId}")
    void delete(int userId);


}
